
var aj = [], am = null, ap = 0;
var ar = document.createElement("div");
ar.id = "module_proxy";
ar.className = "mProxy";
var DDModules = function () {
	this.av = false;
	this.refresh = false;
};
DDModules.prototype.aD = function (A) {
	if (this.av) {
		return;
	}
	this.av = true;
	aj = A;
	for (var D = 0; D < aj.length; D++) {
		for (var E = 0; E < aj[D].childNodes.length - 1; E++) {
			var B = aj[D].childNodes[E];
			var C = document.getElementById(B.id + "_drag");
			if (!C) {
				continue;
			}
			C.module = B;
			DDModules.init(C);
			C.onDragStart = function (D, C) {
				clearInterval(ap);
				var A = this.module;
				DDModules.az(A);
				A.origNextSibling = A.nextSibling;
				var B = DDModules.ah();
				B.innerHTML = A.innerHTML;
				B.style.left = DDModules.ao(A, true) + "px";
				B.style.top = DDModules.ao(A, false) + "px";
				B.style.height = A.offsetHeight + "px";
				B.style.width = A.offsetWidth + "px";
				B.style.display = "block";
				B.style.opacity = 0.5;
				B.style.filter = "alpha(opacity=50)";
				B.className = A.className;
				this.dragged = false;
			};
			C.onDrag = function (B, A) {
				DDModules.aF(this.module, B, A);
				this.dragged = true;
			};
			C.onDragEnd = function (B, A) {
				if (this.dragged) {
					ap = DDModules.aC(this.module, 150, 0);
					DDModules.aw();
				} else {
					DDModules.aw();
				}
				if (this.module.nextSibling != this.module.origNextSibling) {
					DDModules.aw();
					DDModules.aT();
				}
				this.am = null;
			};
		}
	}
};
DDModules.aC = function (A, E, F) {
	var C = this.ah();
	var G = document.getElementById("module_proxy");
	G.parentNode.insertBefore(A, G);
	G.parentNode.removeChild(G);
	A.style.display = "";
	var B = parseInt(C.style.left);
	var D = parseInt(C.style.top);
	var H = (B - this.ao(A, true)) / F;
	var I = (D - this.ao(A, false)) / F;
	return setInterval(function () {
		if (F < 1) {
			clearInterval(ap);
			DDModules.aw();
			return;
		}
		F--;
		B -= H;
		D -= I;
		C.style.left = parseInt(B) + "px";
		C.style.top = parseInt(D) + "px";
	}, E / F);
};
DDModules.aF = function (B, E, F) {
	var C = null;
	var D = 100000000;
	B.style.display = "none";
	for (var H = 0; H < aj.length; H++) {
		for (var I = 0; I < aj[H].childNodes.length; I++) {
			var G = aj[H].childNodes[I];
			if (G == B) {
				continue;
			}
			var A = Math.sqrt(Math.pow(E - G.pagePosLeft, 2) + Math.pow(F - G.pagePosTop, 2));
			if (isNaN(A)) {
				continue;
			}
			if (A < D) {
				D = A;
				C = G;
			}
		}
	}
	if (C != null && ar.nextSibling != C) {
		C.parentNode.insertBefore(ar, C);
		this.aG(B);
	}
};
DDModules.aG = function (A) {
	A.parentNode.style.display = "none";
	A.parentNode.style.display = "";
	this.refresh = true;
};
DDModules.ah = function () {
	if (!am) {
		am = document.createElement("div");
		am.style.position = "absolute";
		am.style.display = "none";
		am.style.border = "solid #C7C7C7 1px";
		am.style.cursor = "move";
		am.style.backgroundColor = "#E3EFFE";
		document.body.appendChild(am);
	}
	return am;
};
DDModules.ao = function (A, B) {
	var C = 0;
	while (A != null) {
		C += A["offset" + (B ? "Left" : "Top")];
		A = A.offsetParent;
	}
	return C;
};
DDModules.aT = function () {
	if (this.refresh) {
		var A = document.getElementById("notice_area");
		if (A.style.display == "none") {
			A.style.display = "";
		}
	}
};
DDModules.aw = function () {
	var noticeArea = this.ah();
	noticeArea.style.display = "none";
};
DDModules.az = function (A) {
	for (var D = 0; D < aj.length; D++) {
		var E = 0;
		for (var B = 0; B < aj[D].childNodes.length; B++) {
			var C = aj[D].childNodes[B];
			if (C == A) {
				E = C.offsetHeight;
			}
			C.pagePosLeft = this.ao(C, true);
			C.pagePosTop = this.ao(C, false) - E;
		}
	}
};
DDModules.obj = null;
DDModules.init = function (A) {
	var B = DDModules.ah();
	A.onmousedown = DDModules.start;
	if (isNaN(parseInt(B.style.left))) {
		B.style.left = "0px";
	}
	if (isNaN(parseInt(B.style.top))) {
		B.style.top = "0px";
	}
	A.onDragStart = function () {
	};
	A.onDragEnd = function () {
	};
	A.onDrag = function () {
	};
};
DDModules.start = function (A) {
	var C = DDModules.ah();
	var D = DDModules.obj = this;
	A = DDModules.fixE(A);
	var E = parseInt(C.style.top);
	var B = parseInt(C.style.left);
	D.onDragStart(B, E, A.clientX, A.clientY);
	D.lastMouseX = A.clientX;
	D.lastMouseY = A.clientY;
	document.onmousemove = DDModules.drag;
	document.onmouseup = DDModules.end;
	return false;
};
DDModules.drag = function (A) {
	var C = DDModules.ah();
	A = DDModules.fixE(A);
	var E = DDModules.obj;
	var F = A.clientY;
	var B = A.clientX;
	var D = parseInt(C.style.top);
	var H = parseInt(C.style.left);
	var I, G;
	I = H + B - E.lastMouseX;
	G = D + F - E.lastMouseY;
	C.style.left = I + "px";
	C.style.top = G + "px";
	E.lastMouseX = B;
	E.lastMouseY = F;
	E.onDrag(I, G, A.clientX, A.clientY);
	return false;
};
DDModules.end = function () {
	var A = DDModules.ah();
	document.onmousemove = null;
	document.onmouseup = null;
	DDModules.obj.onDragEnd(parseInt(A.style.left), parseInt(A.style.top));
	DDModules.obj = null;
};
DDModules.fixE = function (A) {
	if (typeof A == "undefined") {
		A = window.event;
	}
	if (typeof A.layerX == "undefined") {
		A.layerX = A.offsetX;
	}
	if (typeof A.layerY == "undefined") {
		A.layerY = A.offsetY;
	}
	return A;
};

